import { createRouter, createWebHistory } from 'vue-router'
import index from '../views/home/IndexView.vue'
import login from '../views/login/LoginView.vue'
import register from '../views/register/RegisterView.vue'
import DetailProduct from '@/views/detail/DetailProducts.vue'
import CartView from '@/views/cart/CartView.vue'
import BuyOrders from '@/views/orders/BuyOrders.vue'
import NewProducts from '@/views/NewProducts/NewProducts.vue'
import SiFa from '@/views/sifa/SiFa.vue'
import SiIn from '@/views/signin/SiIn.vue'
import MyUser from '@/views/me/MyUser.vue'
import ServiceMsg from '@/views/service/ServiceMsg.vue'
import FeedBack from '@/views/feedback/FeedBack.vue'
import PayOrder from '@/views/payorder/PayOrder.vue'
import RecycleView from '@/views/recycle/RecycleView.vue'
import TopUp from '@/views/topup/TopUp.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: index,
    },
    {
      path: '/login',
      name: 'login',
     component:login
    },
      {
      path: '/register',
      name: 'register',
     component:register
    },
      {
    path: '/product/:id',
    name: 'DetailProduct',
    component: DetailProduct,
    props: true
  },
      {
    path: '/cart',
    name: 'cart',
    component: CartView
  },
    {
    path: '/order',
    name: 'order',
    component: BuyOrders
  },
  {
    path: '/newproducts',
    name: 'newproducts',
    component: NewProducts
  },
   {
    path: '/sifa',
    name: 'sifa',
    component: SiFa
  },
  {
    path: '/signin',
    name: 'signin',
    component: SiIn
  },

  {
    path: '/user',

    component: MyUser,

    // 添加子路由
    children: [
      {
        path: '',
        redirect: '/user/default' // 默认重定向到账户页面
      },
      {
        path: 'orders',
        name: 'userOrders',
        component: () => import('../views/me/order/UserOrders.vue')
      },
      {
        path: 'wallet',
        name: 'userWallet',
        component: () => import('../views/me/wallet/UserWallet.vue')
      },
      {
        path: 'account',
        name: 'userAccount',
        component: () => import('../views/me/account/UserAccount.vue')
      },
       {
        path: 'address',
        name: 'userAddress',
        component: () => import('../views/me/address/UserAddress.vue')
      },
        {
        path: 'coupons',
        name: 'userCoupons',
        component: () => import('../views/me/coupons/UserCoupons.vue')
      },
      {
        path: 'activities',
        name: 'userActivities',
        component: () => import('../views/me/activities/UserActivities.vue')
      },
      {
        path: 'default',
        name: 'default',
        component: () => import('../views/me/default/DeauFlt.vue')
      },
    ]
  },
   {
    path: '/service',
    name: 'service',
    component: ServiceMsg
  },
   {
    path: '/feedback',
    name: 'feedback',
    component: FeedBack
  },
   {
    path: '/payorder',
    name: 'payorder',
    component: PayOrder
  },
   {
    path: '/recyle',
    name: 'recyle',
    component: RecycleView
  },
{
    path: '/topup',
    name: 'topup',
    component: TopUp
  },
  ],
})

export default router
